﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Calendar.aspx.cs" Inherits="ZX.WebApp.Crm.Hodometer.Calendar" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>一推讲师行程</title>
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/reset-fonts-grids/reset-fonts-grids.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/resize/resize-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>
    <link rel="stylesheet" href="style/StyleSheet1.css" />
    <link href="../../Styles/extendTable.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style7
        {
            border-bottom: black 1px solid;
            background-color: white;
            overflow: hidden;
            height: 100%;
            width: 95%;
        }
        .BulletedList
        {
            margin-left:15px;
            overflow: hidden;
            height: 100%;
            width: 95%;
            line-height:25px;
        }
</style>
    <script language="javascript" type="text/javascript">
        function $(id) { return document.getElementById(id) }
        function ReviewForm(obj) {
            //空值隐藏
            var strs = null;
            var arr = new Array("MintCream", "MistyRose", "Moccasin", "NavajoWhite", "Orange", "PowderBlue", "Tan", "Transparent", "Yellow", "SeaGreen", "Snow", "Teal", "LightBlue", "LightCoral", "LightCyan", "LightGoldenrodYellow", "LightGray", "LightGreen", "LightPink", "LightSalmon", "LightSeaGreen", "LightSkyBlue", "LightSlateGray", "LightSteelBlue", "LightYellow");

            if (obj != null && obj != "") {
                strs = obj.split(';');
            }
            for (var i = 1; i < 7; i++) {
                var tb = $("tb" + i + i + "0");
                if (tb != null)
                    tb.style.visibility = "hidden";
            }
            //周末变色
            var sp1 = $("sp1");
            if (sp1 != null)
                sp1.style.color = "red";
            for (var i = 7; i < 36; i++) {
                if (i % 7 == 0) {
                    var sp = $("sp" + i);
                    var sp1 = $("sp" + (i + 1));
                    if (sp != null)
                        sp.style.color = "red";
                    if (sp1 != null)
                        sp1.style.color = "red";
                }
            }

            for (var j = 1; j < 32; j++) {
                var taa = $("Tasw" + j);
                setValue(taa);
                var tap = $("Taxw" + j);
                setValue(tap);
                var tan = $("Taws" + j);
                setValue(tan);

                if (strs != null && strs != "") {
                    //底色变化
                    for (var k = 0, l = strs.length; k < (l - 1); k++) {
                        if (taa == null)
                            break;
                        if (contains(taa.value, strs[k], true)) {
                            taa.style.backgroundColor = arr[k];
                        }
                        if (contains(tap.value, strs[k], true)) {
                            tap.style.backgroundColor = arr[k];
                        }
                        if (contains(tan.value, strs[k], true)) {
                            tan.style.backgroundColor = arr[k];
                        }

                    }
                }
            }
        }

        function setValue(ta) {
            var us = document.getElementById("hdfadduser");
            var bl = false;
            if (us.value == "TRUE" || us.value == "") {
                bl = true;
            }
            if (ta != null && ta.value != "") {
                var hdcid = getnextnextobj(ta);
                var val = ta.value.split('[');
                if(!bl) {
                    var usl = ta.value.split('}--');
                    if (us.value != usl[1]) {
                        ta.ondblclick = null;
                        return;
                    }
                }
                var oLink = document.createElement("a");
                oLink.href = "#";
                oLink.id = hdcid.value;
                oLink.onclick = (function pop() { hrefModify(hdcid.value); });
                oLink.innerHTML = "<font  color=blue>" + val[0] + "</font>";
                ta.value = "";
                var oL = document.createElement("a");
                oL.innerHTML = "[" + val[1];
                ta.appendChild(oLink);
                ta.appendChild(oL);
            }
        }
        //链接跳到查看客户信息
        function hrefModify(id) {
            var temAvail = "<%=getRoleCondition() %>";
            if (temAvail.length > 1) {
                var own = temAvail.substr(0, 1);
                var ownName = temAvail.substr(1, temAvail.length - 1);
                if (own == "0") {
                    if (ownName != document.getElementById("dl_Calendar_Labteacher").innerHTML) {
                        alert("您暂时无权查看该客户信息");
                        return;
                    }
                }
            }
            var pagetitle = "查看客户信息";
            parent.$("#tabs").tabs('close', pagetitle);
            parent.addTabs(pagetitle, '../Crm/Customer/AddCustomer.aspx?entity=CrmCustomer&title=' + encodeURI(pagetitle) + '&id=' + id);

        }
        function getnextnextobj(obj) {
            var n = obj; //$("Tasw11");
            var next;
            do n = n.nextSibling;
            while (n && n.nodeType != 1);
            next = n.id;

            var n1 = $(next);
            do n1 = n1.nextSibling;
            while (n1 && n1.nodeType != 1);
            //alert(n1.id);
            return n1;
        }
        // string:原始字符串
        //substr:子字符串
        //isIgnoreCase:忽略大小写
        function contains(string, substr, isIgnoreCase) {
            if (isIgnoreCase) {
                string = string.toLowerCase();
                substr = substr.toLowerCase();
            }
            var startChar = substr.substring(0, 1);
            var strLen = substr.length;
            for (var j = 0; j < string.length - strLen + 1; j++) {
                if (string.charAt(j) == startChar)  //如果匹配起始字符,开始查找
                {
                    if (string.substring(j, j + strLen) == substr)  //如果从j开始的字符与str匹配，那ok
                    {
                        return true;
                    }
                }
            }
            return false;
        }
    </script>
</head>
<body class="yui-skin-sam" onload="pageonload();">
    <form id="form1" runat="server">
    <div style="background-color:#F2F2F2;">
    <div id="Left"  class="calendar-container"  style="width:8%; min-height:1302px; height:100%;  background-color:#F2F2F2; font-size:medium;  float:left;">
    <p style="margin-top:5px; color:Black;">讲师：</p>
    <p style="margin-top:5px;"><input type="text" style="width:60px" runat="server" id="teacherName" /> <asp:Button ID="btnSeach" runat="server" Text="搜索" Class="btnCheck" OnClick ="btnSerch_OnClick"/></p>
    <asp:BulletedList ID="blInnerTeacher" runat="server" CssClass="BulletedList"  DisplayMode="LinkButton"  OnClick ="blInnerTeacher_OnClick"
              BorderColor="#99CCFF">
    </asp:BulletedList>
    </div>
    <div id="right" style=" width:92%; float:right;">
    <div class="calendar-container" id="calendar-container"><asp:HiddenField ID="hdfadduser" runat="server" Value="" />
        <asp:DataList ID="dl_Calendar" Width="100%" runat="server" BorderColor="#99CCFF"
            BorderWidth="1px" CellPadding="1" GridLines="Both" RepeatColumns="7" RepeatDirection="Horizontal"
            OnItemDataBound="dl_Calendar_ItemDataBound">
            <HeaderTemplate>
                <table style="width: 100%; line-height: 35px; text-align: center; " border="0">
                    <tr>
                        <td style="width: 14%; text-align: right;font-size:medium;
                     ">
                            当前讲师：
                        </td>
                        <td style="width: 14%; text-align: left;">
                           <asp:Label ID="Labteacher" runat="server" Text=""></asp:Label>
                        </td>
                        <td style="width: 15%; text-align: right;font-size: x-large;
                    font-weight: bolder;">
                            <asp:LinkButton ID="lbtnYearPre" runat="server" Font-Underline="false" CssClass="Edit"
                                CommandName="PreY" OnCommand="dl_Command" Text="<<"></asp:LinkButton>&nbsp;&nbsp;&nbsp;
                            <asp:LinkButton ID="btn_Edit" runat="server" Font-Underline="false" CssClass="Edit"
                                CommandName="Pre" OnCommand="dl_Command" Text="<"></asp:LinkButton>
                        </td>
                        <td style="width: 14%; text-align: center;font-size: x-large;
                    font-weight: bolder;">
                            <asp:Label runat="server" ForeColor="blue" ID="lab_Time"></asp:Label>
                        </td>
                        <td style="width: 15%; text-align: left;font-size: x-large;
                    font-weight: bolder;">
                            <asp:LinkButton ID="lbtnMonthNext" runat="server" CssClass="Edit" Font-Underline="false"
                                CommandName="Next" OnCommand="dl_Command" Text=">"></asp:LinkButton>&nbsp;&nbsp;&nbsp;
                            <asp:LinkButton ID="lbtnYearNext" runat="server" Font-Underline="false" CssClass="Edit"
                                CommandName="NextY" OnCommand="dl_Command" Text=">>"></asp:LinkButton>
                        </td>
                        <td style="width: 28%;" colspan="2">
                            <span style="font-size: small; font-weight: lighter; line-height: 18px;">《显示格式》：公司名[决策人](职位){上课地点}{上课时间}--添加人</span>
                        </td>
                    </tr>
                    <tr style="padding: 1px; border-top: 1px solid #b8cede;font-size: x-large;
                    font-weight: bolder;">
                        <td style="color: Red; text-align: center;">
                            <span>日</span>
                        </td>
                        <td style="text-align: center;">
                            <span>一</span>
                        </td>
                        <td style="text-align: center;">
                            <span>二</span>
                        </td>
                        <td style="text-align: center;">
                            <span>三</span>
                        </td>
                        <td style="text-align: center;">
                            <span>四</span>
                        </td>
                        <td style="text-align: center;">
                            <span>五</span>
                        </td>
                        <td style="color: Red; text-align: center;">
                            <span>六</span>
                        </td>
                    </tr>
                </table>
            </HeaderTemplate>
            <ItemTemplate>
                <table id="tb<%#Eval("DTime") %>" cellpadding="0" cellspacing="0" style="width: 100%;
                    visibility: visible;">
                    <tr>
                        <td colspan="2" style="text-align: center; font-size: x-large; font-weight: bold;">
                            <span id="sp<%#Eval("Nums") %>">
                                <%#Eval("DTime") %></span>
                        </td>
                    </tr>
                    <tr style="padding: 1px; border-top: 1px solid #b8cede;">
                        <td style="width: 10%;">
                            <%#Eval("SW") %>
                        </td>
                        <td style="width: 90%;">
                            <textarea id="Tasw<%#Eval("DTime") %>" title='<%#Eval("SWname") %>' rows="4" ondblclick="tadbclick(this)"
                                class="style7"><%#Eval("SWname") %></textarea>
                            <asp:HiddenField runat="server" ID="hdfswid" Value='<%#Eval("SWid") %>' />
                            <asp:HiddenField runat="server" ID="hdfswcusid" Value='<%#Eval("SWCusid") %>' />
                        </td>
                    </tr>
                    <tr style="padding: 1px; border-top: 1px solid #b8cede;">
                        <td>
                            <%#Eval("XW") %>
                        </td>
                        <td>
                            <textarea id="Taxw<%#Eval("DTime") %>" rows="4" title='<%#Eval("XWname") %>' ondblclick="tadbclick(this)"
                                class="style7"><%#Eval("XWname") %></textarea>
                            <asp:HiddenField runat="server" ID="hdfxwid" Value='<%#Eval("XWid") %>' />
                            <asp:HiddenField runat="server" ID="hdfxwcus" Value='<%#Eval("XWCusid") %>' />
                        </td>
                    </tr>
                    <tr style="padding: 1px; border-top: 1px solid #b8cede;">
                        <td>
                            <%#Eval("WS") %>
                        </td>
                        <td>
                            <textarea id="Taws<%#Eval("DTime") %>" rows="4" title='<%#Eval("WSname") %>' ondblclick="tadbclick(this)"
                                class="style7"><%#Eval("WSname") %></textarea>
                            <asp:HiddenField runat="server" ID="hdfwsid" Value='<%#Eval("WSid") %>' />
                            <asp:HiddenField runat="server" ID="hdfwscusid" Value='<%#Eval("WSCusid") %>' />
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
            <ItemStyle Width="14%" />
        </asp:DataList>
    </div>
    <div id="dialog1" class="yui-pe-content">
        <div class="hd">
            客户选择</div>
        <div class="bd">
            <iframe id="EditUIWindow" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    <script language="javascript" type="text/javascript">

        YAHOO.namespace("example.container");
        YAHOO.util.Event.onDOMReady(function () {
            var handleSubmit = function () {
                var editwindow = document.getElementById("EditUIWindow");
                if (editwindow) {
                    if(editwindow.contentWindow.Save())
                        this.cancel();
                }
            };
            var handleCancel = function () {
                this.cancel();
            };
            var handleFailure = function (o) {
                alert("Submission failed: " + o.status);
            };
            YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
							        { width: "500px",
							            height: "500px",
							            fixedcenter: true,
							            visible: false,
							            draggable: true,
							            close: true,
							            autofillheight: "body",
							            constraintoviewport: true,
							            buttons: [{ text: "保存", handler: handleSubmit, isDefault: true },
								      { text: "取消", handler: handleCancel}]
							        });
            YAHOO.example.container.dialog1.render();
        });



        function tadbclick(obj) {
            var next;
            var n = obj;
            do n = n.nextSibling;
            while (n && n.nodeType != 1);
            next = $(n.id);
            if (queryString("TYPE") == null) {//新增讲师行程
                return;
                var nowdate = '<%= RebackDate %>';
                var d = obj.id.substring(4)
                var ym = $("dl_Calendar_lab_Time");
                var ddl = $("dl_Calendar_ddlteach");
                var teaid = '<%= SelectTea %>';
                var dated = ym.innerHTML + "-" + d;
                if ((new Date(nowdate.replace(/-/g,"/"))) > (new Date(dated.replace(/-/g,"/")))) {
                    alert("该行程日期已过去，不能新增或修改！");
                    return false;
                }
                else {
                    document.getElementById("EditUIWindow").src = "CustomerCheck.aspx?CCID=" + next.value + "&TA=" + obj.id + "&HD=" + n.id + "&TEAID=" + teaid + "&DATED=" + dated;
                    YAHOO.example.container.dialog1.show();
                }
            }
            else {//讲师行程总结
                if (next.value == "") {

                }
                else {
                    var temAvail = "<%=getRoleCondition() %>";
                    var tempState = 0;
                    if (temAvail.length > 1) {
                        var own = temAvail.substr(0, 1);
                        var ownName = temAvail.substr(1, temAvail.length - 1);
                        if (own == "0") {
                            if (ownName != document.getElementById("dl_Calendar_Labteacher").innerHTML) {
                                tempState = 1;
                                parent.addTabs('讲师演讲总结', '../Crm/Sale/AddTeachSumup.aspx?own=0&ID=' + next.value);
                                parent.NeedRefreshPage = this;
                            }
                        }
                    }
                    if (tempState==0) {
                        parent.addTabs('讲师演讲总结', '../Crm/Sale/AddTeachSumup.aspx?ID=' + next.value);
                        parent.NeedRefreshPage = this;
                    }  
                }
            }
        }
        //只取一个URL参数：
        var queryString = function (key) {
            return (document.location.search.match(new RegExp("(?:^\\?|&)" + key + "=(.*?)(?=&|$)")) || ['', null])[1];
        }

        function pageonload() {
            var val = queryString("TYPE");
            if (val != null && val == "1") {
                //document.getElementById("Left").style.display = "none";
                //document.getElementById("right").style.width = "100%";
            }
        }
    </script>
    </div>
    </div>
    </form>
</body>
</html>
